<%@ page import="bcared.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>

<% 
	Boolean isResolved = false;

	if (request.getParameter("checkinsubmit") != null) {
		CheckInOut check = new CheckInOut(Integer.parseInt(request.getParameter("engineerID")), 1, " ", isResolved);
		
		Engineer e = new Engineer(Integer.parseInt(request.getParameter("engineerID")));
		ServiceOrder so = new ServiceOrder(e.getSOID());
		
		if (e.getRoleID() == 4) {
			so.setSoStatusID(8);
		} else {
			so.setSoStatusID(9);
		}
		so.update();
	}
	else if (request.getParameter("checkoutsubmit") != null) {
		if (request.getParameter("isResolved") != null) {
			isResolved = true;
		}	
		CheckInOut check = new CheckInOut(Integer.parseInt(request.getParameter("engineerID")), 2, request.getParameter("ResNotes"), isResolved);
		Engineer e = new Engineer(Integer.parseInt(request.getParameter("engineerID")));
		ServiceOrder so = new ServiceOrder(e.getSOID());
		if (isResolved) {
			so.setSoStatusID(1);
		} else {
			so.setSoStatusID(6);
		}
		so.update();
		e.clearSOID();
	}

%>

<% 
	response.sendRedirect("EngineerHome.jsp?userid=" + request.getParameter("userid") + "&msgid=" + request.getParameter("msgid"));
%>
